import { BreakpointsClassInfix } from "./enums";
interface AnyAttrObj {
  [name: string]: any;
}
interface ColObj {
  colCls?: BreakpointsClassInfix;
  colSize?: number;
}
export default {
  paddingZero(str: string | number, len?: number): string {
    len = len || 8;
    str = str + "";
    const strLen = str.length;
    if (strLen >= len) return str;
    return new Array(len - strLen + 1).join("0") + str;
  },
  getSubObj(obj: AnyAttrObj | undefined, keys: string[]): any {
    if (!obj) return {};
    const result: any = {};
    keys.forEach((key) => {
      result[key] = obj[key];
    });
    return result;
  },
  getColClass(obj: ColObj) {
    const result: (string | number)[] = ["col"];
    if (obj.colCls) {
      result.push(obj.colCls);
    }
    if (obj.colSize) {
      result.push(obj.colSize);
    }
    return result.join("-");
  },
};
